package UHFTest;

public class UHFUtil {

    public static String byteToString(byte[] b) {
        StringBuffer sb = new StringBuffer("");
        for (int i = 0; i < b.length; i++) {
            String temp = Integer.toHexString(b[i] & 0xff);
            if (temp.length() == 1) {
                temp = "0" + temp;
            }
            sb.append(temp);
        }
        return sb.toString().toUpperCase();
    }

    public static byte[] stringToByte(String str) {
        byte[] b = new byte[str.length() / 2];
        for (int i = 0; i < str.length() / 2; i++) {
            b[i] = (byte) (0xff & Integer.parseInt(str.substring(i * 2, i * 2 + 2), 16));
        }
        return b;
    }



}
